<template>
  <div class="c-top-bg c-text-hidden c-ph24 c-p c-pb20">
    <img src="https://kposshzcdn.ckjr001.com/admin/material/9_material_admin/image/public/i/wap/coupon/giftBox.png" class="c-ww280 c-pa c-p-t16 c-p-r0">
    <div class="c-fs36 c-fc-white c-mt40 c-lh50 textShadow">此券适用以下商品</div>
    <div @click="showNotice = true" class="c-fs22 c-fc-white c-ph24 c-pv4 c-translucent-balck10 c-br24 c-mt20 c-inlineblack">使用须知</div>
    <div class="c-bg-white c-br16 c-mt40 c-pv32 c-ph24 c-p c-pz10">
      <!-- 只能兑换一个商品的兑换券，领取兑换券后直接兑换成功，到此页面不需要再领取，所以不用展示时间 -->
      <template v-if="!(cType == 1 && exchangeArr.length == 1 && exchangeArr[0].prodInfo.used == 1)">
        <div class="c-flex-row c-aligni-center c-justify-center">
          <div class="c-textAlign-c timeBg c-inlineblack c-br16 c-text-hidden" v-if="redeemCodeInfo.status == 1 || redeemCodeInfo.status == 2 || redeemCodeInfo.status == 3">
            <cj-clocker :useBjTime="true" :time="timeFn()" @on-finish="finishFn()">
              <template v-slot="{ timeInfo }">
                <div class="c-fs22 c-ph24 c-pv16 c-fc-sblack c-flex-row c-aligni-center c-justify-center">
                  <div>距离{{redeemCodeInfo.status == 1 ? '开始' : '结束'}}还剩</div>
                  <div class="c-mr10"><span class="c-fc-xblack c-fw-b c-ph10">{{timeInfo.D}}</span>天</div>
                  <div class="c-ww44 c-hh28 c-textAlign-c c-lh28 c-bg-sblack c-fc-white c-br4">{{timeInfo.H}}</div>
                  <div class="c-ph10">:</div>
                  <div class="c-ww44 c-hh28 c-textAlign-c c-lh28 c-bg-sblack c-fc-white c-br4">{{timeInfo.M}}</div>
                  <div class="c-ph10">:</div>
                  <div class="c-ww44 c-hh28 c-textAlign-c c-lh28 c-bg-sblack c-fc-white c-br4">{{timeInfo.S}}</div>
                </div>
              </template>
            </cj-clocker>
          </div>
          <div v-else class="c-fs24 c-fc-sblack c-mt32 c-textAlign-c">{{redeemCodeInfo.status == 4 ? '已结束' : ''}}</div>
        </div>
      </template>
      <div v-if="redeemCodeInfo">
        <div @click="goProduct(item.prodInfo.prodType, item.prodInfo.id, item.prodInfo.courseType)" class="c-flex-row c-aligni-start c-pt30" :class="index == (exchangeArr.length - 1) ? '' : 'c-bd-b1 c-pb30'" v-for="(item, index) in exchangeArr" :key="index">
          <div v-if="item.prodInfo.prodType != 86" class="c-ww160 c-maxh106 c-text-hidden c-br4 c-flex-shrink0">
            <img v-if="item.prodInfo.prodType == 1 || item.prodInfo.prodType == 23" class="c-w100 c-br4" :src="$addXossFilter((item.prodInfo.avatar && item.prodInfo.avatar.coverType == 2) ? item.prodInfo.avatar.coverUrl : (item.prodInfo.avatar && item.prodInfo.avatar.coverType == 1) ? require('../../../assets/i/wap/vip/vip-bg-mb' + item.prodInfo.avatar.coverUrl + '.png') :  (item.prodInfo.prodType == 1 ? require('@/assets/i/wap/course/vip.png') : require('@/assets/i/wap/course/svip.png')))" alt="">
            <img v-else class="c-w100 c-br4" :src="$addXossFilter(item.prodInfo.avatar ? item.prodInfo.avatar : item.prodInfo.prodType == 11 ? require('../../../assets/examination_defult.png') : require('../../../assets/defult270.png'))" alt="">
          </div>
          <div v-else class="c-ww160 c-hh106 c-flex-row c-justify-center c-flex-shrink0">
            <img class="c-ww106 c-hh106 c-br56" :src="$addXossFilter(item.prodInfo.avatar, require('../../../assets/defult270.png'))" alt="">
          </div>
          <div class="c-flex-column c-justify-sb c-w0 c-flex-grow1 c-pl20">
            <div class="c-fs24 c-fw400 c-fc-xblack c-text-ellipsis2"><span class="c-fs22 c-fc-mred c-inlineblack bg-red c-ph6 c-mr6 c-br4" v-if="item.prodInfo.isMarket == 1">参与限时购</span>{{item.prodInfo.name}}</div>
            <div class="c-fs20 c-fc-gray c-mt8" v-if="item.prodInfo.prodType == 118">此课程仅支持线下报名，请联系商家使用优惠券报名</div>
            <div class="c-flex-row c-justify-sb c-aligni-center c-mt24" v-if="item.prodInfo.prodType != 118">
              <div v-if="!((item.prodInfo.prodType == 1 || item.prodInfo.prodType == 23) && Number(item.prodInfo.effective) > 0)" class="c-fc-xmlred c-fs26 c-fw400">
                <span v-if="item.prodInfo.payType == 2 || item.prodInfo.payType == 4">{{'￥' | iosPriceFilter}}</span>{{item.prodInfo.payType | priceValueFilter(item.prodInfo.prodPrice, item.prodInfo.prodType)}}
              </div>
              <div v-else></div>
              <template v-if="cType == 1">
                <div @click.stop="goProduct(item.prodInfo.prodType, item.prodInfo.id, item.prodInfo.courseType)" v-if="item.prodInfo.permission==1" class="c-fs20 c-fc-white c-fw400 c-ww110 c-hh44 c-br24 btn-bg c-flex-row c-flex-center">查看</div>
                <div @click.stop="" v-else-if="item.prodInfo.used == 1 && exchangeArr.length == 1" class="c-fs20 c-fc-white c-fw400 c-ww110 c-hh44 c-br24 c-bg-ccc c-flex-row c-flex-center">兑换成功</div>
                <div @click.stop="" v-else-if="((item.prodInfo.permission==0 || ((item.prodInfo.prodType == 1 || item.prodInfo.prodType == 23) && Number(item.prodInfo.effective) > 0)) && (redeemCodeInfo.useStatus == 1 || redeemCodeInfo.status == 1 || redeemCodeInfo.status == 5))||item.prodInfo.btnStatus==0" class="c-fs20 c-fc-white c-fw400 c-ww110 c-hh44 c-br24 c-bg-ccc c-flex-row c-flex-center">去兑换</div>
                <div @click.stop="goToExchange(item, index)" v-else-if="item.prodInfo.permission==0 || ((item.prodInfo.prodType == 1 || item.prodInfo.prodType == 23) && Number(item.prodInfo.effective) > 0)" class="c-fs20 c-fc-white c-fw400 c-ww110 c-hh44 c-br24 btn-bg c-flex-row c-flex-center">去兑换</div>
              </template>
              <template v-else-if="cType == 4">
                <div @click.stop="" v-if="(redeemCodeInfo.useStatus == 1 || redeemCodeInfo.status == 1)||item.prodInfo.btnStatus==0" class="c-fs20 c-fc-white c-fw400 c-ww110 c-hh44 c-br24 c-bg-ccc c-flex-row c-flex-center">去预约</div>
                <div @click.stop="goToBooking(item, index)" v-else class="c-fs20 c-fc-white c-fw400 c-ww110 c-hh44 c-br24 btn-bg c-flex-row c-flex-center">去预约</div>
              </template>
              <template v-else>
                <!-- 没有权限 && （使用过了 || 未开始） -->
                <div @click.stop="" v-if="(item.prodInfo.permission==0 && (redeemCodeInfo.useStatus == 1 || redeemCodeInfo.status == 1 || redeemCodeInfo.status == 5 || item.prodInfo.isMarket == 1))||item.prodInfo.btnStatus==0" class="c-fs20 c-fc-white c-fw400 c-ww110 c-hh44 c-br24 c-bg-ccc c-flex-row c-flex-center">优惠购</div>
                <div @click.stop="goProduct(item.prodInfo.prodType, item.prodInfo.id, item.prodInfo.courseType)" v-else-if="item.prodInfo.permission==0" class="c-fs20 c-fc-white c-fw400 c-ww110 c-hh44 c-br24 btn-bg c-flex-row c-flex-center">优惠购</div>
                <div @click.stop="goProduct(item.prodInfo.prodType, item.prodInfo.id, item.prodInfo.courseType)" v-if="item.prodInfo.permission==1" class="c-fs20 c-fc-white c-fw400 c-ww110 c-hh44 c-br24 btn-bg c-flex-row c-flex-center">查看</div>
              </template>
            </div>
          </div>
        </div>
        <loading-status-tem :showLoading="pageLoading" :noData="exchangeArr.length == 0" :noDataText="'暂无商品'"></loading-status-tem>
      </div>
      <div v-if="!is_page" class="c-fs22 c-fc-gray c-textAlign-c c-pv6 c-mt24">没有更多了，<span v-if="redeemCodeInfo.type == 4" @click="goBookingList" class="c-fc-xmlred">师资列表</span><span v-else @click="goHome" class="c-fc-xmlred c-fw-b c-text-decoration-underline">首页逛逛</span></div>
    </div>
    <open-modal :openModal='showNotice' @closeModal='showNotice = false'>
      <div class="c-bg-white c-br-tl24 c-br-tr24 c-pv24 c-ph24 c-p">
        <div class="c-fs26 c-fc-xblack c-fw-b c-textAlign-c">使用须知</div>
        <div class="c-fs24 c-fc-xblack c-fw-b c-mt40">使用时间：</div>
        <div class="c-fs22 c-fc-sblack c-mt10">{{redeemCodeInfo.startAt}} 至 {{redeemCodeInfo.endAt}}</div>
        <div class="c-fs24 c-fc-xblack c-fw-b c-mt40">优惠内容</div>
        <div class="c-fs22 c-fc-sblack c-mt10">
          {{redeemCodeInfo.type == 1 || redeemCodeInfo.type == 4
            ? '可兑换指定商品'
            : redeemCodeInfo.type == 2
              ? (redeemCodeInfo.redeemType == 24 ? '指定商品满任意金额可用' : redeemCodeInfo.redeemType == 25 ? '商城商品满任意金额可用' : '全部商品满任意金额可用')
              : (redeemCodeInfo.redeemType == 24 ? ('指定商品满' + redeemCodeInfo.amount +'元可用') : redeemCodeInfo.redeemType == 25 ? ('商城商品满' + redeemCodeInfo.amount +'元可用') : ('全部商品满' + redeemCodeInfo.amount +'元可用'))}}
        </div>
        <div class="c-fs24 c-fc-xblack c-fw-b c-mt40">使用说明</div>
        <div class="c-fs22 c-fc-sblack c-mt10">每张券只能使用一次</div>
        <div v-if="redeemCodeInfo.validStatus == 1 || redeemCodeInfo.validStatus == 2" class="c-fs22 c-fc-sblack c-mt10">活动时间：{{redeemCodeInfo.validStatus == 1 ? ('领券当日起' + redeemCodeInfo.validPeriod + '天内可用') : ('领券次日起' + redeemCodeInfo.validPeriod + '天内可用')}}</div>
        <div @click="showNotice = false" class="c-fs24 c-fc-sgray c-pa c-p-t24 c-p-r32 iconfont">&#xe8fd;</div>
      </div>
    </open-modal>
  </div>
</template>
<script>
import OpenModal from "@/components/templates/common/openModal.vue";
import loadingStatusTem from "@/components/templates/common/loadingStatusTem.vue";
import { utilJs } from "@/utils/common.js";
import { goDetails } from "@/utils/goDetails.js";
let isLoading = false;
export default {
  name: 'ToExchange',
  components: {
    OpenModal,
    loadingStatusTem
  },
  data() {
    return {
      theme: localStorage.getItem("colorName") ? localStorage.getItem("colorName") : 'mb5_default',
      exchangeCode: "",
      redeemCodeInfo: "",
      cType: 1,
      toExchangeName: '',
      toExchangeId: 0,
      toExchangeType: 0,
      is_page: false,
      page: 1,
      exchangeArr: [],
      pageLoading: false,
      showNotice: false,
      ckFrom: global.ckFrom,
    }
  },
  created() {
    utilJs.appShare(this);
  },
  mounted() { },
  computed: {},
  watch: {},
  methods: {
    toExchangeActivity(data = {}, rcdId, ticketId) {
      let goPathQuery = {
        activityId: data.activityId,
        ticketId: ticketId,
        isFree: data.isFree,
        isAudit: data.isAudit,
        recType: '',
        recRelateId: '',
        ticketName: data.name,
        minNum: 1,
        maxNum: 1,
        selectPrice: 0,
        rcdId: rcdId
      };
      //如果有关联表单，先跳表单页填写完再到填票页
      let path = '/activity/activityEnroll';
      let query = goPathQuery;
      // collectPage：1购买前 && 有关联表单 && 未填写过关联表单 && 有打开表单模块
      if (data.collectPage == 1 && data.isRelForm == true && data.hasFormLog == false && localStorage.getItem("showForm") == 1) {
        path = '/homePage/form';
        query = {
          cId: -1,
          extId: data.activityId,
          ckFrom: global.ckFrom.activity,
          relType: 7,
          type: 1,
          rcdId: rcdId,
          goBillQuery: encodeURIComponent(JSON.stringify(goPathQuery))
        }
      }
      this.$routerGo(this, "push", {
        path: path,
        query: query
      })
    },
    // 获取活动信息
    getActivityInfo(activityId, rcdId, ticketId) {
      utilJs.postMethod(`${global.apiurl}activities/mgticket`, { activityId: activityId, collageId: -1, groupId: -1 }, (res) => {
        const list = res.data || []
        const formRet = res.formRet || {}
        let ticketItem = list.filter(i => i.prodId == ticketId)[0] || {}
        ticketItem = {...formRet, ...ticketItem}
        let stime = ticketItem ? utilJs.getTimeByDate(ticketItem.startAt) : 0;
        let etime = ticketItem ? utilJs.getTimeByDate(ticketItem.endAt) : 0;
        let nowTime = this.getCurrentBeijingTimestamp(); //(new Date()).getTime();
        if (stime && stime > nowTime) {
          this.$showCjToast({ text: "活动报名未开始，不支持兑换", type: "warn", time: 3000 });
          return
        }
        if (etime && etime < nowTime) {
          this.$showCjToast({ text: "活动报名已结束，不支持兑换", type: "warn", time: 3000 });
          return
        }
        if (!ticketItem.prodId) {
          this.$showCjToast({ text: "兑换的活动票已删除，不支持继续兑换", type: "warn", time: 3000 });
          return
        }
        this.toExchangeActivity(ticketItem, rcdId, ticketId)
      });
    },
    goBookingList: function () {
      this.$routerGo(this, "push", {
        path: `/homePage/booking/bookingList`,
      });
    },
    goHome: function () {
      if (this.redeemCodeInfo.redeemType == 25) {
        this.$routerGo(this, "push", {path: "/mall/classification/classificationAll"});
      } else {
        this.$routerGo(this, "push", {path: "/"});
      }
    },
    showConfirmExchangeTip() {
      this.$cjConfirm({
        title: '确认兑换以下商品？',
        message: this.toExchangeName,
        onConfirm:() => {
          this.confirmExchange();
        }
      })
    },
    confirmExchange: function () {
      if (isLoading) {
        return;
      }
      isLoading = true;
      let postUrl = `${global.apiurl}redeemCodes/selectProdToRedeem/${this.exchangeCode}`;
      utilJs.postMethod(postUrl, {prodId: this.toExchangeId, prodType: this.toExchangeType}, res => {
        this.redeemCodeInfo.useStatus = 1;
        if (this.exchangeArr[this.toExchangeIndex].prodInfo.prodType == global.ckFrom.shopping) {
          this.getShopInfo(this.exchangeArr[this.toExchangeIndex].prodInfo.id, this.exchangeCode);
        } else {
          this.exchangeArr[this.toExchangeIndex].prodInfo.permission = 1;
          this.$showCjToast({
            text: "兑换成功",
            type: "success"
          });
        }
        isLoading = false;
      }, failRes => {
        isLoading = false;
      })
    },
    goToExchange: function (eItem, eIndex) {
      this.toExchangeId = eItem.prodInfo.id;
      this.toExchangeName = eItem.prodInfo.name;
      this.toExchangeType = eItem.prodInfo.prodType;
      this.toExchangeIndex = eIndex;
      // 活动类型先走报名流程再兑换
      if (this.redeemCodeInfo.type == 1 && eItem.prodInfo.prodType == global.ckFrom.activity) {
        this.getActivityInfo(eItem.prodInfo.id, this.exchangeCode, eItem.subId)
      } else if (eItem.prodInfo.prodType == global.ckFrom.shopping) {
        this.confirmExchange()
      } else {
        this.showConfirmExchangeTip();
      }
    },
    getShopInfo(prodId, rcdId) {
      utilJs.getMethod(
        global.apiurl + "goods/goodsDetail?mgId=" + prodId + "&rcdId=" + rcdId,
        res => {
          if (res && res.redeemCodeData && res.redeemCodeData.status == 1) {
              this.shopInfo = res.goods;
              this.freeShipping = res.freeShipping;
              this.payAwardData = res.payAwardData;
              let shopInfo = [
                {
                  mgId: this.shopInfo.mgId,
                  mcId: "",
                  avatar: this.shopInfo.avatar ? this.shopInfo.avatar : "",
                  pointsDeduct: 0,
                  name: this.shopInfo.name,
                  price: 0,
                  originalPrice: this.shopInfo.originalPrice,
                  quantity: 1,
                  shopSpecInfo: "",
                  gsiiId: "",
                  postage: this.shopInfo.postage,
                  isMail: this.shopInfo.isMail,
                  isMallExpressDeliver: this.shopInfo.isMallExpressDeliver,
                  isMallOfflineDeliver: this.shopInfo.isMallOfflineDeliver,
                  stock: 1,
                  salesStock: "",
                  collageStock: "",
                  freeShipping: this.freeShipping,
                  isFlashSales: false,
                  isCollage: false,
                  pId: "",
                  noLimit: false,
                  vipDiscount: 0,
                  svipDiscount: 0,
                  agentDiscount: 0,
                  partnerDiscount: 0,
                  branchDiscount: 0,
                  isExchange: true,
                  limitType: -1,
                  limitNumber: 0,
                  purchasedNum: 0,
                  vipDiscountType: this.shopInfo.vipDiscountType || 1,
                  realPrice: this.shopInfo.price
                }
              ];
              sessionStorage.setItem("shopBuyInfo", JSON.stringify(shopInfo));
              let goPath = "/mall/shopSettlement/shopSettlement?shopNo=" + prodId + "&rcdId=" + rcdId;
              this.$routerGo(this, "push", {
                path: goPath
              });
          } else {
            this.$showCjToast({
              text: "兑换失败",
              type: "warn",
            });
          }
        }
      );
    },
    goToBooking: function (bItem, bIndex) {
      this.$routerGo(this, "push", {
        path: "/homePage/booking/bookingTime",
        query: {
          atId: bItem.prodInfo.id,
          ckFrom: global.ckFrom.booking
        }
      });
    },
    getCurrentBeijingTimestamp() {
      const now = new Date(); // 获取当前时间
      const utcTime = new Date(now.getTime() + (now.getTimezoneOffset() * 60000)); // 转换为UTC时间
      const beijingTime = new Date(utcTime.getTime() + (8 * 60 * 60 * 1000)); // 转换为北京时间
      return beijingTime.getTime(); // 返回北京时间的时间戳
    },
    finishFn: function () {
      if (this.redeemCodeInfo.status == 1) {
        this.redeemCodeInfo.status = 2;
        this.timeFn();
      } else {
        this.redeemCodeInfo.status = 4;
      }
    },
    timeFn: function () {
      let stime = this.redeemCodeInfo ? utilJs.getTimeByDate(this.redeemCodeInfo.startAt) : 0;
      let etime = this.redeemCodeInfo ? utilJs.getTimeByDate(this.redeemCodeInfo.endAt) : 0;
      let nowTime = this.getCurrentBeijingTimestamp(); //(new Date()).getTime();
      let time = '';
      if (stime > nowTime) {
        this.redeemCodeInfo.status = 1;
        time = this.redeemCodeInfo.startAt;
      } else if (etime > nowTime) {
        this.redeemCodeInfo.status = 2;
        time = this.redeemCodeInfo.endAt;
      }
      return time;
    },
    goToTicket(item) { // 点击查看票券
      this.$routerGo(this, "push", {
        path: `/activity/myTicket`,
        query: {
          activityId: item.id,
          identCode: item.identCode,
          asId: 0
        }
      });
    },
    goProduct: function (rType, rId, courseType, codeType, permission) {
      if (codeType == 1) {
        localStorage.setItem("couponType", 1);
        this.$routerGo(this, "push", {
          path: "/member/myValueVoucher/myValueVoucher"
        });
      } else {
        if (rType == 26) {
          this.$routerGo(this, "push", {path: "/"});
        } else if ((rType == 1 || rType == 23) && this.cType == 1) {
          this.$routerGo(this, "push", {
            path: "/member/memberIndex"
          });
        } else {
          goDetails(this, rType, rId, '', courseType);
        }
      }
    },
    // 获取可用该券的产品
    getCouponInfo: function () {
      if (this.pageLoading) {
        return;
      }
      this.pageLoading = true;
      let postUrl = `${global.apiurl}redeemCodes/getProdsByRedeemCodeDetail/${this.exchangeCode}?page=${this.page}&limit=15`;
      utilJs.getMethod(postUrl, res => {
        this.pageLoading = false;
        if (this.page == 1) {
          this.redeemCodeInfo = res;
        }
        this.cType = res.type;
        this.exchangeArr = this.exchangeArr.concat(res.prods.data);

        this.page = res.to < res.total ? (this.page + 1) : this.page;
        this.is_page = res.to < res.total ? true : false;
        this.wechatShare();
      }, failRes => {
        this.pageLoading = false;
      })
    },
    //下滑获取更多
    windowScrollFunction: function () {
      let that = this;
      utilJs.handleLoading(function () {
        if (that.is_page == true) {
          that.getCouponInfo();
        }
      });
    },
    //分享
    wechatShare: function () {
      let title = this.redeemCodeInfo == null ? "快来领取兑换码" : this.redeemCodeInfo.name;
      let shareImg = 'https://kposshzcdn.ckjr001.com/admin/material/9_material_admin/image/public/i/wap/coupon/share.png' || window.localStorage.getItem("shareLogo");
      let shareUrl = "";
      // 有绑定服务商，推荐人id为服务商id，否则为当前用户id
      if (!this.redeemCodeInfo.presenterUserId || this.redeemCodeInfo.presenterUserId == -1) {
        shareUrl = `${window.location.href.split("#")[0]}#/homePage/giftcode/${this.redeemCodeInfo.redeemCodeId}?type=1&refereeId=${localStorage.getItem("userId")}`;
      } else {
        shareUrl = `${window.location.href.split("#")[0]}#/homePage/giftcode/${this.redeemCodeInfo.redeemCodeId}?type=1&refereeId=${this.redeemCodeInfo.presenterUserId}`;
      }
      let shareDesc = this.redeemCodeInfo.type == 1 ? "您有个兑换券可以领取，名额有限，快来领取吧！" : "您有个优惠券可以领取，名额有限，快来领取吧！";
      if (!this.redeemCodeInfo.enableShare || this.redeemCodeInfo.enableShare == -1) {
        utilJs.wechatConfig(shareUrl, title, shareImg, shareDesc, function () { }, false, { hideAllNonBaseMenuItem: 1 });
      } else {
        utilJs.wechatConfig(shareUrl, title, shareImg, shareDesc, function () { }, true, { hideAllNonBaseMenuItem: 0 });
      }
    },
    //手机端分享
    appShare: function () {
      let title = this.redeemCodeInfo == null ? "快来领取兑换码" : this.redeemCodeInfo.name;
      let shareImg = 'https://kposshzcdn.ckjr001.com/admin/material/9_material_admin/image/public/i/wap/coupon/share.png' || window.localStorage.getItem("shareLogo");
      let shareUrl = "";
      // 有绑定服务商，推荐人id为服务商id，否则为当前用户id
      if (!this.redeemCodeInfo.presenterUserId || this.redeemCodeInfo.presenterUserId == -1) {
        shareUrl = `${window.location.href.split("#")[0]}#/homePage/giftcode/${this.redeemCodeInfo.redeemCodeId}?type=1&refereeId=${localStorage.getItem("userId")}`;
      } else {
        shareUrl = `${window.location.href.split("#")[0]}#/homePage/giftcode/${this.redeemCodeInfo.redeemCodeId}?type=1&refereeId=${this.redeemCodeInfo.presenterUserId}`;
      }
      let shareDesc = this.redeemCodeInfo.type == 1 ? "您有个兑换券可以领取，名额有限，快来领取吧！" : "您有个优惠券可以领取，名额有限，快来领取吧！";
      if (!this.redeemCodeInfo.enableShare || this.redeemCodeInfo.enableShare == -1) {
        utilJs.appShareTrue(title, shareImg, shareUrl, shareDesc, function () { }, false, { hideAllNonBaseMenuItem: 1 });
      } else {
        utilJs.appShareTrue(title, shareImg, shareUrl, shareDesc, function () { }, true, { hideAllNonBaseMenuItem: 0 });
      }
    },
  },
  activated() {
    this.exchangeCode = this.$route.query.eExchangeCode;
    // this.cType = this.$route.query.cType; //1，兑换码，2代金券（无门槛），3满减券  4:抵价券 5:折扣券
    this.is_page = false;
    this.page = 1;
    this.redeemCodeInfo = "";
    this.exchangeArr = [];
    this.pageLoading = false;
    isLoading = false;
    this.getCouponInfo();
    window.addEventListener('scroll', this.windowScrollFunction);
  },
  deactivated() {
    window.removeEventListener('scroll', this.windowScrollFunction);
  }
}
</script>
<style scoped>
.c-top-bg {
  background: linear-gradient(90deg, #EC3D35 0%, #EF6B66 100%);
}
.c-hh106 {
  height: 2.65rem;
}
.c-br56 {
  border-radius: 1.4rem;
}
.c-ww106 {
  width: 2.65rem;
}
.bg-red {
  background-color: rgba(255, 125, 120, 0.3);
}
.btn-bg {
  background: linear-gradient(90deg,#ff300c, rgba(255,48,12,0.70));
}
.c-translucent-balck10 {
  background-color: rgba(0, 0, 0, 0.1);
}
.timeBg {
  background: rgba(236,61,53,0.10);
}
.textShadow {
  text-shadow: 0px 2px 0 rgb(139, 5, 0, 0.5)
}
</style>

